Developer Documentation
PATH  WebObjects 4.0 Documentation > WebObjects Tools and Techniques

Table of Contents Previous Section

Generating Components

When you have worked with the WebAssistant and customized your pages to your liking, you may still want to add more features to your application. To do so, you can "freeze" a page; that is, save it as a WebObjects component. When you do this, the component becomes part of your project and is no longer created "on the fly" by Direct to Web. This has several advantages:

The main disadvantage of generating components is that you lose the ability to modify settings with the WebAssistant. Therefore, you should try to get your settings as close as possible to what you want before generating the component.

To save a page as a component:

  1. Click the Expert Mode button at the bottom of the WebAssistant to enter Expert mode.

  2. Click Customize Page at the top of the WebAssistant.

  3. Select the task and entity corresponding to the page you want to generate.

    You can't select "*all*" to generate multiple components. You must generate the components one at a time.

  4. In the Advanced Options group of controls, make sure the "Choose DirectToWeb page" radio button is selected.

  5. Click Generate.

    The Freeze Component window appears. It contains a text field with a default name for your page (the page name followed by the entity name). You can edit the name if you choose.

  6. Click the Ok button.

    Direct to Web generates a component and adds it to your project. (You may have to wait a few moments for this process to complete.) Your settings are automatically saved.

  7. Rebuild your project.
To "un-freeze" a component, select the "Choose DirectToWeb page" radio button but do not click the Generate button.

When you generate a page and click Update, the browser's current page doesn't reflect the changes. To use the new component, you must rebuild the application, relaunch it, and then navigate to a new instance of the page. For example, if the current page is a Movie query page, and you use the WebAssistant to freeze it, you must rebuild the project with the frozen component, then launch the application and navigate to a new instance of Movie query (by clicking Build Query); the new instance uses the frozen component.

The generated component is like any other WebObjects component. You can edit your component graphically using WebObjects Builder. You can also examine the HTML and bindings (.wod file) of the new component in Project Builder.

Direct to Web also generates Java code for your component, which you can modify appropriate to your needs. Each component implements an interface that is appropriate to the page: QueryPageInterface, ListPageInterface, InspectPageInterface, and EditPageInterface. For example, the QueryMovieRole.java file shown below implements the QueryPageInterface. For example, it contains an action method called queryClicked that returns a component when the Query DB button is clicked. (Note that the component's submit button is bound to queryClicked in QueryMovieRole.wod.)

Table of Contents Next Section